/* type A = string & number;

type Foo = string | number | boolean | undefined | null | void | never;

type Method = 'GET' | 'POST' | 'PUT' | 'DELETE' ;

function request(url:string, method:Method) {
  if (method === 'GET') {
    console.log(method, url);
  }
  else if (method === 'POST') {
    console.log(method, url);
  }
  else { 
    const _neverCheck: never = method;
    console.log(method)
    throw new Error(`不知道的类型: ${_neverCheck}`);
  }
}

request("http://www.google.com", "GET") */

type Circle = { kind: "circle", radius: number }
type Rect = { kind: "rect", width: number, height: number }
type Triangle = { kind: "triangle", base: number, height: number }
type Shape = Circle | Rect | Triangle;

function area(shape: Shape) {
  switch (shape.kind) {
    case "circle":
      return Math.PI * shape.radius ** 2;
    case "rect":
      return shape.width * shape.height;
    case "triangle":
      return shape.base * shape.height / 2;
    default:
      const _neverCheck: never = shape; 
      throw new Error("Invalid shape type");
  }
}

function fn(): never { 
  // todos ...
  throw new Error("error");
}

function foo(n: number) { 
  if (n > 10) { 
    fn();
    let name = "foo";
    // ....
  }
}